<?php

class category extends cls_parent {

    private $tbl = "categories";

    public function getCategories() {
        $sql = "select * from categories where parent_id is null ";
        return $this->db->fetchAll($sql);
    }

    public function addCategories($data = array()) {
        $this->db->prepareInsert($data);
        $this->db->insert($this->tbl);
    }
    
    public function getSubCategories($i) {
        $sql = "select * from categories where parent_id = $i";
        return $this->db->fetchAll($sql);
    }
       

}
//SELECT root.cat_id as cid, root.name as cname, down1.cat_id as cid1, down1.name as cname1
//            FROM categories AS root 
//            LEFT OUTER JOIN
//            categories AS down1
//            ON root.cat_id = down1.parent_id
//            WHERE root.parent_id IS NULL

?>